package com.redijedi.tapestry5.internal;

import java.util.Map;

import com.redijedi.tapestry5.TreeNodeModel;

/**
 * @author torr
 * 
 */
public class TreeNodeModelImpl implements TreeNodeModel {

	private final String _id;

	private final String _label;

	private final Object _value;

	private final int _depth;

	private final Map<String, String> _attributes;

	public TreeNodeModelImpl(String id, String label, Object value, int depth,
			String... keysAndValues) {
		this(id, label, value, depth, keysAndValues.length > 0 ? InternalUtils
				.mapFromKeysAndValues(keysAndValues) : null);
	}

	public TreeNodeModelImpl(String id, String label, Object value, int depth,
			Map<String, String> attributes) {
		_id = id;
		_label = label;
		_value = value;
		_depth = depth;
		_attributes = attributes;
	}

	public Map<String, String> getAttributes() {
		return _attributes;
	}

	public String getId() {
		return _id;
	}

	public String getLabel() {
		return _label;
	}

	public Object getValue() {
		return _value;
	}

	public int getDepth() {
		return _depth;
	}

	@Override
	public String toString() {
		return String.format("TreeNodeModel[%s %s %d]", _label, _value, _depth);
	}
}
